package ch.fhnw.qualiscan.application.models;

import java.util.List;

import ch.fhnw.qualiscan.core.Model;
import ch.fhnw.qualiscan.core.db.pojos.Language;

public class LanguageModel extends Model {

	@SuppressWarnings("unchecked")
	public List<Language> getLanguages() { 
		List<Language> languages = hibernateSession.getSession().createQuery("from Language as lang").list();
		return languages;
	}
	
	public boolean getLanguage(String locale) {
		Language language = (Language) hibernateSession.getSession().createQuery("from Language as lang where lang.locale = :locale")
		.setParameter("locale", locale)
		.uniqueResult();
		
		if(language == null) {
			return false;
		} else {
			return true;
		}
	}
	
}
